#include <iostream>
#include <cstdio>
using namespace std;
void fnl(int a, int b) {
    if (a==b) {
        cout<<1<<endl;
        return;
    }
    if (a==0) {
        cout<<0<<endl;
        return;
    }
    for (int i=2; i<a+1&&i<b+1; i++) {
        if (a%i==0 && b%i==0) {
            a=a/i;
            b=b/i;
            i=1;
        }
    }
    cout<<a<<'/'<<b<<endl;
}
int main() {
    string a,b;
    int max,count;
    while (cin>>a && a!="-1") {
        cin>>b;
        max=0;
        for (int i=0; i<a.length(); i++) {
            for (int j=0; j<b.length(); j++) {
                int x=i;
                int y=j;
                count=0;
                for (int k=0; x+k<a.length() || y+k<b.length(); k++) {
                    if (a[x+k]==b[y+k]) count++;
                }
                if (count>max) max=count;
            }
        }
        printf ("appx(%s,%s) = ",a.c_str(),b.c_str());
        fnl(max*2,a.length()+b.length());
    }
    return 0;
}
